//
//  MTPopMenuCell.swift
//  MTPopMenuDemo
//
//  Created by Mengql on 2018/6/7.
//  Copyright © 2016 etiaolong. All rights reserved.
//

import UIKit

class MTPopMenuCell: UITableViewCell {
    private let titleLab: UILabel = {
        let label = UILabel()
        return label
    }()
    var isShowSeparator: Bool = false {
        didSet {
            setNeedsDisplay()
        }
    }
    var separatorColor: UIColor = UIColor.lightGray {
        didSet {
            setNeedsDisplay()
        }
    }
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        contentView.addSubview(titleLab)
        
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        titleLab.frame = contentView.bounds
    }
    override func draw(_ rect: CGRect) {
        super.draw(rect)
        if !isShowSeparator {
            return
        }
        let bezierPath = UIBezierPath(rect: CGRect(x: 0, y: rect.size.height - 0.5, width: rect.size.width, height: 0.5))
        separatorColor.setFill()
        bezierPath.fill(with: .normal, alpha: 1)
        bezierPath.close()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
